package com.eso.frame.core;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * DAO接口
 * User: Noah.Rong
 * Version: 0.1,  2012-05-22 16:18
 */
public interface IDao {
    public JdbcTemplate getJdbcTemplate();

    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate();

    public Object get(Class entityClass, Serializable id) throws DataAccessException;

    public Object get(String entityName, Serializable id) throws DataAccessException;

    public Object load(Class entityClass, Serializable id) throws DataAccessException;

    public Object load(String entityName, Serializable id) throws DataAccessException;

    public List loadAll(Class entityClass);

    public void refresh(Object entity);

    public boolean contains(Object entity) throws DataAccessException;

    public void evict(Object entity) throws DataAccessException;

    public Serializable save(Object entity) throws DataAccessException;

    public Serializable save(String entityName, Object entity);

    public void update(Object entity);

    public void update(String entityName, Object entity);

    public void saveOrUpdate(Object entity);

    public void saveOrUpdateAll(Collection entities);

    public void persist(final Object entity);

    public Object merge(Object entity);

    public void delete(Object entity) throws DataAccessException;

    public void deleteAll(Collection entities);

    public List find(String queryString);

    public List find(String queryString, int firstResult, int maxResults);

    public List find(String queryString, Object[] params, int firstResult, int maxResults);

    public Long findCount(final String queryString, final Map<String, Object> paramMap);

    public List find(String queryString, Object value);

    public List find(String queryString, Object... values);

    public List findByNamedParam(String queryString, String paramName, Object value);

    public List findByNamedParam(String queryString, String[] paramNames, Object[] values);

    public List findByValueBean(String queryString, Object valueBean);

    public List findByCriteria(DetachedCriteria criteria);

    public List findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults);

    public List findByExample(Object exampleEntity);

    public List findByExample(String entityName, Object exampleEntity);

    public List findByExample(Object exampleEntity, int firstResult, int maxResults);

    public Iterator iterate(String queryString);

    public Iterator iterate(String queryString, Object value);

    public Iterator iterate(String queryString, Object... values);

    List findPageByHql(String queryString, Object[] params, Integer firstResult, Integer pageSize);

    public Integer execute(String hql, Object[] params);
}
